from flask import Flask,render_template,request,escape

app = Flask(__name__)

def log_request(req:"flask_request",res:str):
	with open("laoyou.txt","a") as log:
		print(str(dir(req)),res,file = log)

@app.route("/")
def Hello():
	return "Hello"

@app.route("/entry")
def hello_entry():
	return render_template("entry.html",the_title = "hello_entry web")

@app.route("/search",methods = ["POST"])
def Hello_search():
	phrase = request.form["phrase"]
	letters = request.form["letters"]
	results = phrase + letters
	log_request(request,results)
	return results

@app.route("/viewlog")
def hello_viewlog():
	with open("laoyou.txt","r") as log:
		contents = log.read()
	return escape(contents)

if __name__ == "__main__":
	app.run(debug=True)